package com.wjb.xietong.util;

import android.util.Log;



public class LogD {
	/**
	 * Wrapper API for logging
	 */
	protected final static String TAG = "WJB"; // /< LOG TAG
	protected final static int LOG_OUTPUT_MAX_LENGTH = 100;// 每行最大长度


	public static void output(String msg) {
		wrapperMsg(msg);
	}

	/**
	 * Wrapper the message
	 * 
	 * @param msg
	 *            : The message to wrapper
	 */
	protected static void wrapperMsg(String msg) {
		if (null == msg) {
			return;
		}
		
		while(msg.length() > LOG_OUTPUT_MAX_LENGTH){
			final String tempMsg = msg.substring(0, LOG_OUTPUT_MAX_LENGTH);
			msg = msg.substring(LOG_OUTPUT_MAX_LENGTH, msg.length());
			Log.d(TAG, tempMsg);
		}

		StackTraceElement elem = new Throwable().fillInStackTrace()
				.getStackTrace()[2];
		Log.d(TAG, msg + "(" + elem.getFileName() + " : " + elem.getLineNumber() + ")");
		
	}
}
